#include "user.h"
#include <QDebug>
#include "main.h"

user::user(QString nid,QString nname,QString nip,QString job,QPixmap npicture):
    id(nid),name(nname),ip(nip),picture(npicture)
  // , chat(NULL)
{
    //msg = new message(chat, name,"暂时没有新消息",picture,"16:15");
    //smsg = new small_message(chat, name, picture);
   // ChatWidget w(db.GetFriend(id.toInt()));
}

void user::set_name(QString new_name){
    name = new_name;
}
void user::set_ip(QString new_ip){
    ip = new_ip;
}
void user::set_picture(QString path){
    picture = QPixmap(path);
}

void user::show_chat(){
    if(chat&&(!chat->visibleRegion().isEmpty())){
        qDebug() <<"弹出原聊天框";
        chat->activateWindow();
        chat->setWindowState((chat->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
    }
    else{
        qDebug() <<"产生新聊天框";
        //chat_widget_list[id.toInt()]=&w;
        //chat = new chatwindow();
        //chat->show();
    }
}
